<?php
    /**
    * Meeting Approve
    */
    if (!defined('EXPONENT')) exit('');
    if (exponent_users_isAdmin() ||  exponent_permissions_check(array("administrate","meeting"),exponent_core_makeLocation("profilemodule","_syscore","")))
    {
        $meeting=null;
        if (isset($_REQUEST['id']))
        {
            $meeting=$db->selectObject('profilemodule_meeting','id='.intval($_REQUEST['id']));
        }
        if (isset($meeting->id))
        {
            global $user;
            $meeting->approve_date = time();
            $meeting->approve_by = "{$user->firstname} {$user->lastname}({$user->username})";
            $meeting->approve_state = intval($_REQUEST['approve_state']);
            $meeting->approve_note = $_REQUEST['approve_note'];
            $meeting->last_update = time();
            $meeting->last_update_by = $meeting->approve_by;
            
            $listapprove= array('New','Not approve','Approved','Meeting done');
            profilemodule::_meeting_history_add($meeting->id,'Meeting '.$listapprove[$meeting->approve_state].' by '.$user->username,$listapprove[$meeting->approve_state]);
            
            
            $db->updateObject($meeting,'profilemodule_meeting');
            echo "OK";
        }
        else
        {
            echo "";
        }
    }
    else
        exponent_http_error(403);

?>
